<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //ES6 新增了let命令，用来声明变量。它的用法类似于var，但是所声明的变量，只在let命令所在的代码块内有效。
        {
            let a = 10;
            var b = 1;
        }
        //console.log(a);// ReferenceError: a is not defined.
        console.log(b);// 1

        //for循环的计数器，就很合适使用let命令。
        for (let i = 0; i < 10; i++) {
            // ...
        }
        console.log(i);// ReferenceError: i is not defined
    </script>
</body>
</html>